package com.yuexun.dhdoctor.module.mythings.presenter.impl;



import com.yuexun.dhdoctor.base.BaseEntity;
import com.yuexun.dhdoctor.module.mythings.bean.SignDtlData;
import com.yuexun.dhdoctor.module.mythings.model.IThingModel;
import com.yuexun.dhdoctor.module.mythings.presenter.ISignDtlPresenter;
import com.yuexun.dhdoctor.module.mythings.ui.view.ISignDtlView;

import org.kymjs.kjframe.ui.ViewInject;

import java.util.Map;

import rx.Subscriber;
import rx.android.schedulers.AndroidSchedulers;
import rx.schedulers.Schedulers;

/**
 * Created by Administrator on 2017/5/12 0012.
 */

public class SignDtlPresenter implements ISignDtlPresenter {

    private ISignDtlView view;
    private IThingModel model;

    //记录Log
//    private final Logger log = ProUtil.getLogger(LoginPresneter.class);

    public SignDtlPresenter(IThingModel model, ISignDtlView view) {
        this.model = model;
        this.view = view;
    }

    @Override
    public void getDtlList(Map<String, String> praise) {
        model.getDtlList(praise)
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(new Subscriber<BaseEntity<SignDtlData>>() {

                    @Override
                    public void onCompleted() {

                    }

                    @Override
                    public void onError(Throwable e) {
                        ViewInject.toast("请检查网络状态");
                    }

                    @Override
                    public void onNext(BaseEntity<SignDtlData> baseEntity) {
                        view.getDtlList(baseEntity);
                    }
                });
    }
}
